package com.shouhuobao.bhi.loc;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.collectplus.express.R;
import com.collectplus.express.model.LocationBean;

import droid.frame.activity.base.BaseAdapterExt;

/**
 * 上门地址|常用地址
 * 
 * @author coffee <br>
 *         2016-9-29下午1:33:14
 */
public class LocationAdapter extends BaseAdapterExt<LocationBean> {

	public LocationAdapter(ArrayList<LocationBean> items, Activity context) {
		super(items, context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(R.layout.location_item, parent, false);
			holder = new ViewHolder();
			holder.location = (TextView) convertView.findViewById(R.id.location_text);
			holder.selected = (ImageView) convertView.findViewById(R.id.location_selected);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		LocationBean item = getItem(position);
		holder.location.setText(item.getAddress());
		if (item.isSelect()) {
			holder.selected.setVisibility(View.VISIBLE);
		} else {
			holder.selected.setVisibility(View.INVISIBLE);
		}
		return convertView;
	}

	private class ViewHolder {
		TextView location;
		ImageView selected;// 选中标识
	}
}
